import mockjs from "mockjs";

import { resultSuccess } from "./_util";

const data = {
  current_user: {
    email: "tony.li@veolia.com",
    id: "1448937117689450496",
    name: "tony li",
    username: "tony.li",
  },
  dict_data_map: {
    AUDIT_STATUS: [
      {
        dict_code: "AUDIT_STATUS",
        label: "待审核",
        value: "1"
      }
    ]
  },

  menu_tree: [
    {
      cn_name: "页面",
      en_name: "Pages",
      icon: 'icon-yemian-',
      id: "1",
      path: "/app/loong3/pages",
      perms: "prj:pages",
      pid: "0",
      type: 2,
      children: [
        {
          cn_name: "表格",
          en_name: "Table",
          id: "11",
          path: "/app/loong3/pages/table",
          perms: "pages:table",
          pid: "1",
          type: 2,
          children:[
            {
              cn_name: "基础表格",
              en_name: "Basic Table",
              icon: null,
              id: "111",
              path: "/app/loong3/pages/table/basic",
              perms: "pages:table:basic",
              pid: "11",
              type: 2,
            },
            {
              cn_name: "完整表格",
              en_name: "Complete Table",
              icon: null,
              id: "111",
              path: "/app/loong3/pages/table/complete",
              perms: "pages:table:complete",
              pid: "11",
              type: 2,
            }
          ]
        },
        {
          cn_name: "表单",
          en_name: "Form",
          id: "12",
          path: "/app/loong3/pages/form",
          perms: "pages:form",
          pid: "1",
          type: 2,
          children:[
            {
              cn_name: "基础表单",
              en_name: "Basic Form",
              icon: null,
              id: "121",
              path: "/app/loong3/pages/form/basic",
              perms: "pages:form:basic",
              pid: "12",
              type: 2,
            },
            {
              cn_name: "完整表单",
              en_name: "Complete Form",
              icon: null,
              id: "122",
              path: "/app/loong3/pages/form/complete",
              perms: "pages:form:complete",
              pid: "12",
              type: 2,
            }
          ]
        },
        {
          cn_name: "网络请求",
          en_name: "Request",
          id: "13",
          path: "/app/loong3/pages/request",
          perms: "pages:request",
          pid: "1",
          type: 2,
        }
      ]
    },
  ],
  perms_list: ['prj:pages',"pages:table","pages:table:basic","pages:form","pages:form:basic"],
}

const tableList = mockjs.mock({
  current: 1,
  pageSize: 20,
  total: 500,
  "list|500": [{
    "id|+1": 1,
    "name": "@cname(5)",
    "dept_id|1-20": 1,
    "sort|0-1":0,
    "disabled|0-1": 0,
    "email": "@email",
    "create_time": "@datetime",
    "readonly|0-1": 0,
    "update_time": "@datetime",
    "remark":"@cparagraph(5,50)",
  }]
})

const deptList = mockjs.mock({
  "data|1-20": [{
    "id|1-20": 1,
    "name": "@ctitle(5)",
  }]
})

const treeList = {
  data:[
    {
      id:"520000198102026913",
      cname:"星际舰队",
      enname:"Starfleet",
      pid:'0',
      children:[
        {
          id:"350000202301204126",
          cname:"自然选择号",
          enname:"Natural selection",
          pid:'520000198102026913',
        },
        {
          id:"350000202301204127",
          cname:"万有引力号",
          enname:"Gravitational Force",
          pid:'520000198102026913',
        }
      ]
    },
    {
      id:"640000202302225948",
      cname:"联合政府",
      enname:"coalition government",
      pid:'0',
    }
  ]
}

export default [
  {
    url: '/v1/logined_data',
    method: 'get',
    response: () => resultSuccess(data)
  },
  {
    url: '/prj/login',
    method: 'post',
    response: () => resultSuccess({ token: '1234567890' })
  },
  {
    url: '/v1/logout',
    method: 'post',
    response: () => resultSuccess({ data: 'success' })
  },
  {
    url: '/v1/table/list',
    method: 'post',
    response: ({ body: { page, limit } }: { body: { page: number, limit: number } }) => resultSuccess({ ...tableList,current:page,pageSize:limit})
  },
  {
    url: '/v1/dept',
    method: 'get',
    response: () =>  ({ code: 200,message:'ok',...deptList})
  },
  {
    url: '/v1/tree',
    method: 'get',
    response: () =>  ({ code: 200,message:'ok',...treeList})
  }
]
